package org.lys.util;

import java.util.List;

public class Pagination {

	private int pageNow=1;
	private int pageCount=1;
	private int pageSize=10;
	private int rowCount=0;
	
	

	private List data;
	
	private String navigation="";
	private String url;
	
	public int getPageNow() {
		return pageNow;
	}

	public void setPageNow(int pageNow) {
		this.pageNow = pageNow;
	}

	public int getPageCount() {
		return pageCount;
	}

	public void setPageCount(int pageCount) {
		this.pageCount = pageCount;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getRowCount() {
		return rowCount;
	}

	public void setRowCount(int rowCount) {
		this.rowCount = rowCount;
		this.pageCount = (int) Math.ceil(1.0*this.rowCount/this.pageSize);
	}

	public List getData() {
		return data;
	}

	public void setData(List data) {
		this.data = data;
	}

	public String getNavigation() {
		if(pageNow>1){
			navigation = "<a href='"+url+"&pageNow="+(pageNow-1)+"'>上一页</a>";
		}
		if(pageNow<this.pageCount){
			navigation += "&nbsp;&nbsp;&nbsp;<a href='"+url+"&pageNow="+(pageNow+1)+"'>下一页</a>";
		}
		navigation+="&nbsp;&nbsp;第"+pageNow+"页/共"+pageCount+"页";
		return navigation;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public int getBeginRow() {
		return (this.pageNow-1)*this.pageSize;
	}

}
